﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RMS.Common
{
    /// <summary>
    /// 输出到页面Json转换用的结果类
    /// </summary>
    public class CommonOutPutVm
    {
        public CommonOutPutVm()
        {
            IsSuccess = false;
        }
        /// <summary>
        /// 执行是否成功
        /// </summary>
        public bool IsSuccess { get; set; }
        /// <summary>
        /// 动态数据
        /// </summary>
        public dynamic Data { get; set; }
        /// <summary>
        /// 执行后的Id
        /// </summary>
        public string Id { get; set; }
        /// <summary>
        /// 信息（失败时的错误信息等）
        /// </summary>
        public string Message { get; set; }
        /// <summary>
        /// 错误字典用于记录模型验证错误
        /// </summary>
        public Dictionary<string, string> ErrorDic 
        {
            get { return errorDic; }
            set 
            {
                errorDic = value;
                Message = string.Join("<br/>", errorDic.Values);
            }
        }
        private Dictionary<string, string> errorDic;
        /// <summary>
        /// datables控件返回错误
        /// </summary>
        public string error { get { return Message; } }
    }
}
